# Copyright 2023 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:serving.bzl", "serving_cc_binary", "serving_cc_library", "serving_cc_test")

package(default_visibility = ["//visibility:public"])

serving_cc_library(
    name = "ops",
    deps = [
        ":arrow_processing",
        ":dot_product",
        ":merge_y",
    ],
)

serving_cc_library(
    name = "node_def_util",
    srcs = ["node_def_util.cc"],
    hdrs = ["node_def_util.h"],
    deps = [
        "//secretflow_serving/core:exception",
        "//secretflow_serving/protos:graph_cc_proto",
    ],
)

serving_cc_test(
    name = "node_def_util_test",
    srcs = ["node_def_util_test.cc"],
    deps = [
        ":node_def_util",
        "//secretflow_serving/util:utils",
    ],
)

serving_cc_library(
    name = "node",
    srcs = ["node.cc"],
    hdrs = ["node.h"],
    deps = [
        ":op_factory",
        "//secretflow_serving/core:exception",
        "//secretflow_serving/protos:graph_cc_proto",
    ],
)

serving_cc_library(
    name = "graph",
    srcs = ["graph.cc"],
    hdrs = ["graph.h"],
    deps = [
        ":op_factory",
        ":op_kernel_factory",
        "//secretflow_serving/core:exception",
        "//secretflow_serving/protos:graph_cc_proto",
        "@org_apache_arrow//:arrow",
    ],
)

serving_cc_test(
    name = "graph_test",
    srcs = ["graph_test.cc"],
    deps = [
        ":graph",
        ":ops",
        "//secretflow_serving/util:utils",
    ],
)

serving_cc_library(
    name = "op_kernel",
    hdrs = ["op_kernel.h"],
    deps = [
        ":node",
        "//secretflow_serving/core:exception",
        "//secretflow_serving/protos:op_cc_proto",
        "//secretflow_serving/util:arrow_helper",
    ],
)

serving_cc_library(
    name = "op_def_builder",
    srcs = ["op_def_builder.cc"],
    hdrs = ["op_def_builder.h"],
    deps = [
        "//secretflow_serving/core:exception",
        "//secretflow_serving/protos:op_cc_proto",
    ],
)

serving_cc_library(
    name = "op_factory",
    hdrs = ["op_factory.h"],
    deps = [
        ":op_def_builder",
        "//secretflow_serving/core:singleton",
    ],
)

serving_cc_test(
    name = "op_factory_test",
    srcs = ["op_factory_test.cc"],
    deps = [
        ":op_factory",
        "//secretflow_serving/util:utils",
    ],
)

serving_cc_library(
    name = "op_kernel_factory",
    hdrs = ["op_kernel_factory.h"],
    deps = [
        ":op_kernel",
        "//secretflow_serving/core:singleton",
    ],
)

serving_cc_library(
    name = "dot_product",
    srcs = ["dot_product.cc"],
    hdrs = ["dot_product.h"],
    deps = [
        ":node_def_util",
        ":op_factory",
        ":op_kernel_factory",
        "//secretflow_serving/core:types",
        "//secretflow_serving/util:utils",
    ],
    alwayslink = True,
)

serving_cc_test(
    name = "dot_product_test",
    srcs = ["dot_product_test.cc"],
    deps = [
        ":dot_product",
        "//secretflow_serving/util:test_utils",
    ],
)

serving_cc_binary(
    name = "dot_product_benchmark",
    srcs = ["dot_product_benchmark.cc"],
    deps = [
        ":dot_product",
        "@com_github_google_benchmark//:benchmark_main",
    ],
)

serving_cc_library(
    name = "merge_y",
    srcs = ["merge_y.cc"],
    hdrs = ["merge_y.h"],
    deps = [
        ":node_def_util",
        ":op_factory",
        ":op_kernel_factory",
        "//secretflow_serving/core:link_func",
    ],
    alwayslink = True,
)

serving_cc_test(
    name = "merge_y_test",
    srcs = ["merge_y_test.cc"],
    deps = [
        ":merge_y",
        "//secretflow_serving/util:utils",
    ],
)

serving_cc_binary(
    name = "merge_y_benchmark",
    srcs = ["merge_y_benchmark.cc"],
    deps = [
        ":merge_y",
        "//secretflow_serving/util:utils",
        "@com_github_google_benchmark//:benchmark_main",
    ],
)

serving_cc_library(
    name = "arrow_processing",
    srcs = ["arrow_processing.cc"],
    hdrs = ["arrow_processing.h"],
    deps = [
        ":node_def_util",
        ":op_factory",
        ":op_kernel_factory",
        "//secretflow_serving/protos:compute_trace_cc_proto",
    ],
    alwayslink = True,
)

serving_cc_test(
    name = "arrow_processing_test",
    srcs = ["arrow_processing_test.cc"],
    deps = [
        ":arrow_processing",
        "//secretflow_serving/util:test_utils",
        "//secretflow_serving/util:utils",
    ],
)

serving_cc_library(
    name = "graph_version",
    hdrs = ["graph_version.h"],
)
